]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Panel: fix finding leftmost and rightmost buttons
authorGiovanni Campagna <gcampagna@src.gnome.org>
Tue, 17 Jul 2012 17:27:43 +0000 (19:27 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Sat, 21 Jul 2012 13:40:27 +0000 (15:40 +0200)
Previous code would access the array element before checking that
the index was within bounds, and therefore cause a TypeError.
It wasn't noticed earlier because at least one visible children
is in each panel box in all session modes.

https://bugzilla.gnome.org/show_bug.cgi?id=619955

js/ui/panel.js

index c969381af98ed4d299f44b07ba853b1fdfc11154..648a67790ac9558e5d7f8a3b5c6f6835ee054e28 100644 (file)
@@ -753,10 +753,11 @@ const PanelCorner = new Lang.Class({
             return null;
 
         // Start at the back and work backward
-        let index = children.length - 1;
-        while (!children[index].visible && index >= 0)
-            index--;
-
+        let index;
+        for (index = children.length - 1; index >= 0; index--) {
+            if (children[index].visible)
+                break;
+        }
         if (index < 0)
             return null;
 
@@ -777,10 +778,11 @@ const PanelCorner = new Lang.Class({
             return null;
 
         // Start at the front and work forward
-        let index = 0;
-        while (!children[index].visible && index < children.length)
-            index++;
-
+        let index;
+        for (index = 0; index < children.length; index++) {
+            if (children[index].visible)
+                break;
+        }
         if (index == children.length)
             return null;